home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
comm
/
tcp
/
Amster.lha
/
Amster_Install
/
Source
/
gui.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-31
|
24KB
|
685 lines
/*
** GUI Functions
*/
#include "include/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <exec/memory.h>
#include <proto/asl.h>
#include <proto/dos.h>
#include <proto/icon.h>
#include <proto/utility.h>
#include <libraries/gadtools.h>
#include <libraries/asl.h>
#include "include/mui.h"
#include <MUI/Lamp_mcc.h>
#include <MUI/NListview_mcc.h>
#include "include/gui.h"
#include "include/protos.h"
#include "include/channellist.h"
#include "include/napster.h"
#include "include/transfer.h"
#include "include/download.h"
#include "include/upload.h"
#include "include/prefs.h"
#include "include/hotlist.h"
#include "include/info.h"
#include "include/msg.h"
#include "include/navigator.h"
#include "include/rexx.h"
#include "include/search.h"
#include "include/resultview.h"
#include "include/share.h"
#include "include/panel.h"
#include "include/chat.h"
#include "include/about.h"
#include "include/thread.h"
#include "include/url.h"
#include "amster_Cat.h"
struct Library *MUIMasterBase=0;
struct Library *NListBase=0;
struct Library *LampBase=0;
struct Library *TWFBase=0;
int UseLamps = 0;
int UseTWF = 0;
struct guidata mygui;
struct guidata *gui = &mygui;
enum OnlineState gui_onlinestate = OFFLINE;
void gui_free(void);
int gui_setup(void);
MUIF gui_handle(REG(a0) struct Hook *h,REG(a2) Object *app, REG(a1) u_long *id);
void gui_about(void);
void gui_appicon(int t);
struct Hook handleHook = {{0, 0}, &gui_handle, NULL, NULL};
void gui_run(unsigned long tcpsig)
{
ULONG sigs=0;
memset(gui,0,sizeof(struct guidata));
if (gui_setup()) {
prf_event(PRFE_STARTUP);
DoMethod(gui->shwin, SHARE_LOAD);
while (1) {
while (DoMethod(gui->app, MUIM_Application_NewInput, &sigs) != MUIV_Application_ReturnID_Quit) {
if (sigs) {
sigs = Wait(sigs | SIGBREAKF_CTRL_C | tcpsig | th_sigmask);
if (sigs & SIGBREAKF_CTRL_C) break;
if (sigs & tcpsig) nap_listen();
if (sigs & th_sigmask) th_poll();
}
}
if (!dl_count && !ul_count) break;
if ((dl_count || ul_count) && MUI_Request(gui->app, gui->win, 0L,
(char *)MSG_REALLYQUIT_TITLE,
(char *)MSG_REALLYQUIT_GAD,
(char *)MSG_REALLYQUIT)) break;
}
prf_event(PRFE_EXIT);
if (prf->autosave && sharechanged) DoMethod(gui->shwin, SHARE_SAVE);
if (prf->ServerList > 0 && ServerListChanged) DoMethod(gui->WI_Navigator, NAVI_SAVE);
if (HotlistChanged) DoMethod(gui->WI_Hotlist, HOTLIST_SAVE);
if (gui_onlinestate > OFFLINE) nap_logout();
}
gui_free();
}
void gui_free(void)
{
gui_appicon(-1);
if (gui->app) MUI_DisposeObject(gui->app);
lamp_dispose();
if (gui->url_mcc) MUI_DeleteCustomClass(gui->url_mcc);
if (gui->msg_mcc) MUI_DeleteCustomClass(gui->msg_mcc);
if (gui->info_mcc) MUI_DeleteCustomClass(gui->info_mcc);
if (gui->about_mcc) MUI_DeleteCustomClass(gui->about_mcc);
if (gui->prf_mcc) MUI_DeleteCustomClass(gui->prf_mcc);
if (gui->dl_mcc) MUI_DeleteCustomClass(gui->dl_mcc);
if (gui->ul_mcc) MUI_DeleteCustomClass(gui->ul_mcc);
if (gui->share_mcc) MUI_DeleteCustomClass(gui->share_mcc);
if (gui->search_mcc) MUI_DeleteCustomClass(gui->search_mcc);
if (gui->resultview_mcc) MUI_DeleteCustomClass(gui->resultview_mcc);
if (gui->panel_mcc) MUI_DeleteCustomClass(gui->panel_mcc);
if (gui->chat_mcc) MUI_DeleteCustomClass(gui->chat_mcc);
if (gui->navi_mcc) MUI_DeleteCustomClass(gui->navi_mcc);
if (gui->hotlist_mcc) MUI_DeleteCustomClass(gui->hotlist_mcc);
if (gui->channellist_mcc) MUI_DeleteCustomClass(gui->channellist_mcc);
if (MUIMasterBase) CloseLibrary(MUIMasterBase);
}
int gui_setup(void)
{
long winopen;
u_long *MI_Navigator, *MI_Connect, *MI_ConnectTo, *MI_Reconnect, *MI_Disconnect;
u_long *aboutmenu, *muimenu, *helpmenu, *hidemenu, *quitmenu;
u_long *openmenu, *savemenu, *saveasmenu;
u_long *debugmenu, *dlmenu, *ulmenu, *sharemenu, *usermenu, *chatmenu, *MI_Hotlist;
u_long *muiprfmenu, *prfmenu, *MI_LastSaved, *saveprfmenu;
u_long *rxexemenu;
localize_array(nap_linktype);
MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN);
if (!MUIMasterBase) {
printf(MSG_NO_LIBRARY, MUIMASTER_NAME, MUIMASTER_VMIN);
return(0);
}
NListBase = OpenLibrary("MUI/NList.mcc", 19);
if (!NListBase) {
printf(MSG_NO_LIBRARY, "NList.mcc", 19);
return(0);
}
if (NListBase->lib_Version == 19 && NListBase->lib_Revision < 97) {
printf(MSG_NO_LIBRARY, "NList.mcc", 19);
CloseLibrary(NListBase);
return(0);
}
CloseLibrary(NListBase);
LampBase = OpenLibrary("MUI/Lamp.mcc", 11);
if (LampBase) {
if (!(LampBase->lib_Version == 11 && LampBase->lib_Revision == 0))
UseLamps = 1;
CloseLibrary(LampBase);
}
TWFBase = OpenLibrary("MUI/TWFmultiLED.mcc", 12);
if (TWFBase) {
if (!(TWFBase->lib_Version == 12 && TWFBase->lib_Revision < 6))
UseTWF = 1;
CloseLibrary(TWFBase);
}
if (!prf_load("ENV:"AMSTER_PREFS)) prf_load("ENVARC:"AMSTER_PREFS);
lamp_create();
gui->url_mcc = MUI_CreateCustomClass(NULL,MUIC_Text,NULL,sizeof(struct urldata),url_dispatch);
if (!gui->url_mcc) return(0);
gui->panel_mcc = MUI_CreateCustomClass(NULL,MUIC_Group,NULL,sizeof(struct paneldata),panel_dispatch);
if (!gui->panel_mcc) return(0);
gui->search_mcc = MUI_CreateCustomClass(NULL,MUIC_Group,NULL,sizeof(struct searchdata),search_dispatch);
if (!gui->search_mcc) return(0);
gui->resultview_mcc = MUI_CreateCustomClass(NULL,MUIC_Group,NULL,sizeof(struct resultdata),resultview_dispatch);
if (!gui->resultview_mcc) return(0);
gui->dl_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct TransferData),dl_dispatch);
if (!gui->dl_mcc) return(0);
gui->ul_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct TransferData),ul_dispatch);
if (!gui->ul_mcc) return(0);
gui->share_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct shdata),share_dispatch);
if (!gui->share_mcc) return(0);
gui->prf_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct prfdata),prf_dispatch);
if (!gui->prf_mcc) return(0);
gui->info_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct infodata),info_dispatch);
if (!gui->info_mcc) return(0);
gui->about_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct aboutdata),about_dispatch);
if (!gui->about_mcc) return(0);
gui->msg_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct msgdata),msg_dispatch);
if (!gui->msg_mcc) return(0);
gui->chat_mcc = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct chatdata),chat_dispatch);
if (!gui->chat_mcc) return(0);
gui->navi_mcc = MUI_CreateCustomClass(NULL, MUIC_Window, NULL, sizeof(struct NavigatorData), NavigatorDispatch);
if (!gui->navi_mcc) return(0);
gui->hotlist_mcc = MUI_CreateCustomClass(NULL, MUIC_Window, NULL, sizeof(struct HotlistData), HotlistDispatch);
if (!gui->hotlist_mcc) return(0);
gui->channellist_mcc = MUI_CreateCustomClass(NULL, MUIC_Window, NULL, sizeof(struct ChannelListData), ChannelListDispatch);
if (!gui->channellist_mcc) return(0);
gui->iconpanel = NewObject(gui->panel_mcc->mcc_Class, NULL, TAG_DONE);
gui->rect = NULL;
gui->app = ApplicationObject,
MUIA_Application_Title, "Amster",
MUIA_Application_Version, "$VER: Amster "AMSTER_VERSION" ("AMSTER_DATE")",
MUIA_Application_Author, "Jacob Laursen",
MUIA_Application_Description, MSG_CX_DESCRIPTION,
MUIA_Application_Base, "AMSTER",
MUIA_Application_Commands, &rexx_cmds,
MUIA_Application_HelpFile, AMSTER_HELP,
MUIA_Application_Menustrip, MenustripObject,
Child, MenuObject,
MUIA_Menu_Title, MSG_AMSTER_MENU,
Child, MI_Navigator = makemenu(MSG_AMSTER_NAVIGATOR),
Child, makemenu(NULL),
Child, MI_Connect = makemenu(MSG_AMSTER_CONNECT),
Child, MI_ConnectTo = makemenu(MSG_AMSTER_CONNECTTO),
Child, MI_Reconnect = makemenu(MSG_AMSTER_RECONNECT),
Child, MI_Disconnect = makemenu(MSG_AMSTER_DISCONNECT),
Child, makemenu(NULL),
Child, aboutmenu = makemenu(MSG_AMSTER_ABOUT),
Child, muimenu = makemenu(MSG_AMSTER_ABOUTMUI),
Child, helpmenu = makemenu(MSG_AMSTER_HELP),
Child, makemenu(NULL),
Child, hidemenu = makemenu(MSG_AMSTER_HIDE),
Child, quitmenu = makemenu(MSG_AMSTER_QUIT),
End,
Child, MenuObject,
MUIA_Menu_Title, MSG_PROJECT_MENU,
Child, openmenu = makemenu(MSG_PROJECT_OPEN),
Child, savemenu = makemenu(MSG_PROJECT_SAVE),
Child, saveasmenu = makemenu(MSG_PROJECT_SAVEAS),
End,
Child, MenuObject,
MUIA_Menu_Title, MSG_WINDOWS_MENU,
Child, debugmenu = makemenu(MSG_WINDOWS_DEBUG),
Child, sharemenu = makemenu(MSG_WINDOWS_SHARE),
Child, dlmenu = makemenu(MSG_WINDOWS_DOWNLOAD),
Child, ulmenu = makemenu(MSG_WINDOWS_UPLOAD),
Child, usermenu = makemenu(MSG_WINDOWS_USER),
Child, chatmenu = makemenu(MSG_WINDOWS_CHAT),
Child, MI_Hotlist = makemenu(MSG_WINDOWS_HOTLIST),
End,
Child, MenuObject,
MUIA_Menu_Title, MSG_SETTINGS_MENU,
Child, gui->iconpanelmenu = maketmenu(MSG_SETTINGS_ICONPANEL),
Child, makemenu(NULL),
Child, muiprfmenu = makemenu(MSG_SETTINGS_MUI),
Child, prfmenu = makemenu(MSG_SETTINGS_CONFIG),
Child, makemenu(NULL),
Child, MI_LastSaved = makemenu(MSG_SETTINGS_LASTSAVED),
Child, saveprfmenu = makemenu(MSG_SETTINGS_SAVE),
End,
Child, MenuObject,
MUIA_Menu_Title, MSG_AREXX_MENU,
Child, rxexemenu = makemenu(MSG_AREXX_EXECUTE),
End,
End,
SubWindow, gui->win = WindowObject,
MUIA_Window_ID, MAKE_ID('M','A','I','N'),
MUIA_Window_Title, "Amster v"AMSTER_VERSION,
WindowContents, gui->maingrp = HGroup,
Child, VGroup,
Child, gui->searchpanel = NewObject(gui->search_mcc->mcc_Class,NULL,TAG_DONE),
Child, RectangleObject,
MUIA_FixHeight, 8,
MUIA_Rectangle_HBar, TRUE,
End,
Child, gui->statgrp = HGroup,
Child, gui->stat = TextObject,
TextFrame,
MUIA_Background, MUII_TextBack,
MUIA_Text_PreParse, "\33c",
End,
End,
Child, HGroup,
Child, gui->inbut = SimpleButton(MSG_CONNECT_GAD),
Child, gui->outbut = SimpleButton(MSG_DISCONNECT_GAD),
Child, gui->rebut = SimpleButton(MSG_RECONNECT_GAD),
End,
End,
/*
Child, gui->rect = HGroup,
Child, RectangleObject,
MUIA_FixWidth, 4,
MUIA_Rectangle_VBar, TRUE,
End,
Child, gui->iconpanel = NewObject(gui->panel_mcc->mcc_Class, NULL, TAG_DONE),
End,
*/
End,
End,
SubWindow, gui->WI_ConnectTo = WindowObject,
MUIA_HelpNode, "connectto",
MUIA_Window_Title, MSG_CONNECTTO_TITLE,
MUIA_Window_ID, MAKE_ID('C','O','N','N'),
WindowContents, VGroup,
Child, HGroup,
Child, ColGroup(2),
Child, Label2(MSG_CONNECTTO_SERVER),
Child, gui->ST_ConnectServer = StringObject,
StringFrame,
MUIA_String_AdvanceOnCR, TRUE,
MUIA_CycleChain, 1,
End,
Child, Label2(MSG_CONNECTTO_USERNAME),
Child, gui->ST_ConnectUser = StringObject,
StringFrame,
MUIA_String_Reject, ":%$ ",
MUIA_String_AdvanceOnCR, TRUE,
MUIA_CycleChain, 1,
End,
Child, Label2(MSG_CONNECTTO_PASSWORD),
Child, gui->ST_ConnectPw = StringObject,
StringFrame,
MUIA_String_Reject, " ",
MUIA_String_AdvanceOnCR, TRUE,
MUIA_String_Secret, TRUE,
MUIA_CycleChain, 1,
End,
End,
End,
Child, maketoggle(MSG_CONNECTTO_REG, &gui->TG_ConnectReg),
Child, gui->BT_ConnectServer = SimpleButton(MSG_CONNECTTO_CONNECT_GAD),
End,
End,
SubWindow, gui->awin = NewObject(gui->about_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->swin = NewObject(gui->prf_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->iwin = NewObject(gui->info_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->dwin = NewObject(gui->dl_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->uwin = NewObject(gui->ul_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->shwin = NewObject(gui->share_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->mwin = NewObject(gui->msg_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->WI_Navigator = NewObject(gui->navi_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->WI_Hotlist = NewObject(gui->hotlist_mcc->mcc_Class, NULL, TAG_DONE),
SubWindow, gui->WI_ChannelList = NewObject(gui->channellist_mcc->mcc_Class, NULL, TAG_DONE),
End;
if (!gui->app) {
printf(MSG_APP_ERROR);
return(0);
}
DoMethod(gui->inbut,MUIM_Notify,MUIA_Pressed,FALSE,gui->app,3,MUIM_CallHook,&handleHook, CONNECT);
DoMethod(gui->outbut,MUIM_Notify,MUIA_Pressed,FALSE,gui->app,3,MUIM_CallHook,&handleHook, DISCONNECT);
DoMethod(gui->rebut,MUIM_Notify,MUIA_Pressed,FALSE,gui->app,3,MUIM_CallHook,&handleHook, RECONNECT);
DoMethod(gui->iconpanelmenu, MUIM_Notify, MUIA_Menuitem_Checked, MUIV_EveryTime, gui->app, 3, MUIM_CallHook, &handleHook, UPDATEPANEL);
DoMethod(MI_Navigator, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->WI_Navigator, 3, MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(MI_Connect, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->app, 3, MUIM_CallHook, &handleHook, CONNECT);
DoMethod(MI_ConnectTo, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->WI_ConnectTo, 3, MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(MI_Reconnect, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->app, 3, MUIM_CallHook, &handleHook, RECONNECT);
DoMethod(MI_Disconnect, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->app, 3, MUIM_CallHook, &handleHook, DISCONNECT);
DoMethod(gui->WI_ConnectTo, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, gui->WI_ConnectTo, 3, MUIM_Set, MUIA_Window_Open, FALSE);
/* Connect to... */
DoMethod(gui->BT_ConnectServer, MUIM_Notify, MUIA_Pressed, FALSE, gui->app, 3, MUIM_CallHook, &handleHook, CONNECTSERVER);
/* Pulldown menu */
DoMethod(aboutmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->awin,3,MUIM_Set,MUIA_Window_Open,TRUE);
DoMethod(muimenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->app,2,MUIM_Application_AboutMUI,gui->win);
DoMethod(helpmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->app,5,MUIM_Application_ShowHelp,gui->win,AMSTER_HELP,0,0);
DoMethod(hidemenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->app,3,MUIM_Set,MUIA_Application_Iconified,TRUE);
DoMethod(quitmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
DoMethod(openmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->shwin,1,SHARE_LOADAS);
DoMethod(savemenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->shwin,1,SHARE_SAVE);
DoMethod(saveasmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->shwin,1,SHARE_SAVEAS);
DoMethod(debugmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->iconpanel,1,PANEL_OPENDEBUG);
DoMethod(dlmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->iconpanel,1,PANEL_OPENDL);
DoMethod(ulmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->uwin,1,UPLOAD_OPEN);
DoMethod(sharemenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->iconpanel,1,PANEL_OPENSHARE);
DoMethod(usermenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->iconpanel,1,PANEL_OPENMSG);
DoMethod(chatmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->iconpanel,1,PANEL_NEWCHAT);
DoMethod(MI_Hotlist, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->WI_Hotlist, 3, MUIM_Set, MUIA_Window_Open, TRUE);
DoMethod(muiprfmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->app,2,MUIM_Application_OpenConfigWindow,0);
DoMethod(prfmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->iconpanel,1,PANEL_OPENPRF);
DoMethod(MI_LastSaved, MUIM_Notify, MUIA_Menuitem_Trigger, MUIV_EveryTime, gui->swin, 1, PRF_LASTSAVED);
DoMethod(saveprfmenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->swin,1,PRF_SAVEALL);
DoMethod(rxexemenu,MUIM_Notify,MUIA_Menuitem_Trigger,MUIV_EveryTime,gui->app,3,MUIM_CallHook,&handleHook, EXECUTEAREXX);
DoMethod(gui->win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,gui->app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
DoMethod(gui->app, MUIM_Notify, MUIA_Application_Iconified, FALSE, gui->app,3, MUIM_CallHook, &handleHook, DEICONIFIED);
if (UseLamps) DoMethod(gui->statgrp, OM_ADDMEMBER, gui->lamp = LampObject, MUIA_Lamp_Type, MUIV_Lamp_Type_Huge, MUIA_Lamp_Color, MUIV_Lamp_Color_Off, End);
DoMethod(gui->searchpanel, SEARCH_SET);
set(gui->ST_ConnectUser, MUIA_String_Contents, prf->user);
set(gui->ST_ConnectPw, MUIA_String_Contents, prf->pass);
set(gui->TG_ConnectReg, MUIA_Selected, TRUE);
if (prf->noiconpanel) {
set(gui->iconpanelmenu, MUIA_Menuitem_Checked, FALSE);
/* set(gui->rect, MUIA_ShowMe, FALSE);*/
}
else {
set(gui->iconpanelmenu, MUIA_Menuitem_Checked, TRUE);
}
gui_appicon(0);
gui_state(OFFLINE);
if (!UseLamps) gui_debug((char *)MSG_INFO_NOLAMPS);
/* Set screen title for all windows */
DoMethod(gui->app, MUIM_MultiSet, MUIA_Window_ScreenTitle,
"Amster "AMSTER_VERSION" ("AMSTER_DATE") © 1999-2000 Gürer Özen & Jacob Laursen",
gui->win, gui->awin, gui->swin, gui->shwin, gui->mwin, gui->iwin,
gui->dwin, gui->uwin, gui->WI_ConnectTo, gui->WI_Navigator,
gui->WI_Hotlist, gui->WI_ChannelList, NULL);
set(gui->win, MUIA_Window_Open, TRUE);
get(gui->win, MUIA_Window_Open, &winopen);
if (!winopen) {
printf(MSG_ERR_NOWINDOW);
return(0);
}
if (!prf->user) DoMethod(gui->iconpanel, PANEL_OPENPRF);
/* If no account is configured, open configuration window */
if (prf->user && prf->autocon) {
nap_login();
return(1);
}
set(gui->stat, MUIA_Text_Contents, MSG_STATUS2_NOTCONNECTED);
return(1);
}
MUIF gui_handle(REG(a0) struct Hook *h, REG(a2) Object *app, REG(a1) u_long *id)
{
u_long tmp;
char *buf;
switch(*id) {
case CONNECT:
if (gui_onlinestate < CONNECTING) nap_login();
break;
case DISCONNECT:
nap_logout();
set(gui->stat, MUIA_Text_Contents, MSG_STATUS2_NOTCONNECTED);
break;
case RECONNECT:
if (gui_onlinestate > OFFLINE) nap_logout();
nap_login();
break;
case CONNECTSERVER:
if (gui_onlinestate > OFFLINE) nap_logout();
get(gui->ST_ConnectServer, MUIA_String_Contents, &buf);
get(gui->ST_ConnectUser, MUIA_String_Contents, &gui->ConnectUser);
get(gui->ST_ConnectPw, MUIA_String_Contents, &gui->ConnectPw);
get(gui->TG_ConnectReg, MUIA_Selected, &tmp);
set(gui->WI_ConnectTo, MUIA_Window_Open, FALSE);
if (tmp) prf->regflag = 2;
else prf->regflag = 0;
nap_login_fromlist(buf);
break;
case EXECUTEAREXX:
{
BPTR lock;
struct FileRequester *freq;
u_long win;
char DefaultDir[256] = "";
lock = Lock("PROGDIR:Rexx/", ACCESS_READ);
if (lock) {
NameFromLock(lock, DefaultDir, 255);
UnLock(lock);
}
get(gui->win, MUIA_Window_Window, &win);
freq = AllocAslRequestTags(ASL_FileRequest, TAG_DONE);
if (!freq) break;
tmp = AslRequestTags(freq,
ASLFR_Window, win,
ASLFR_TitleText, MSG_SELECTRX_TITLE,
ASLFR_InitialDrawer, DefaultDir,
ASLFR_DoSaveMode, FALSE,
TAG_DONE);
if (tmp) {
static char buf[512];
strcpy(buf, freq->fr_Drawer);
AddPart(buf, freq->fr_File,511);
rexx_execute(buf, NULL);
}
FreeAslRequest(freq);
break;
}
case UPDATEPANEL:
GetAttr(MUIA_Menuitem_Checked, gui->iconpanelmenu, &tmp);
if (tmp==TRUE) {
if (!gui->rect && DoMethod(gui->maingrp, MUIM_Group_InitChange)) {
DoMethod(gui->maingrp, OM_ADDMEMBER,
gui->rect = HGroup,
Child, RectangleObject,
MUIA_FixWidth, 4,
MUIA_Rectangle_VBar, TRUE,
End,
Child, gui->iconpanel,
End);
DoMethod(gui->maingrp, MUIM_Group_ExitChange);
}
}
else {
if (gui->rect && DoMethod(gui->maingrp, MUIM_Group_InitChange)) {
DoMethod(gui->maingrp, OM_REMMEMBER, gui->rect);
DoMethod(gui->maingrp, MUIM_Group_ExitChange);
/* DisposeObject(gui->rect);*/
gui->rect = NULL;
}
}
break;
case DEICONIFIED:
/* Work-around for a bug in Lamp.mcc */
if (gui_onlinestate < CONNECTING) set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_Off);
else if (gui_onlinestate == ONLINE) set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_Ok);
else set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_Connecting);
break;
}
return(0);
}
void gui_state(enum OnlineState s)
{
u_long tmp;
static char title[128];
gui_onlinestate = s;
switch (s) {
case DISCONNECTED:
prf_event(PRFE_DISCONNECT);
DoMethod(gui->WI_Hotlist, HOTLIST_SIGNOFF_ALL);
case OFFLINE: /* Offline */
set(gui->inbut, MUIA_Disabled, FALSE);
set(gui->outbut, MUIA_Disabled, TRUE);
set(gui->rebut, MUIA_Disabled, TRUE);
sprintf(title, "Amster v%s · %s", AMSTER_VERSION, MSG_MAIN_TITLE_NOTCONNECTED);
set(gui->win, MUIA_Window_Title, title);
/* Work-around for a bug in Lamp.mcc */
get(gui->app, MUIA_Application_Iconified, &tmp);
if (!tmp) set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_Off);
DoMethod(gui->searchpanel, SEARCH_CLEAR, CLEAR_ALL);
DoMethod(gui->WI_Hotlist, HOTLIST_CLEAR, CLEAR_ALL);
gui_appicon(2);
break;
case CONNECTING: /* Connecting */
set(gui->inbut, MUIA_Disabled, TRUE);
set(gui->outbut, MUIA_Disabled, FALSE);
sprintf(title, "Amster v%s · %s", AMSTER_VERSION, MSG_MAIN_TITLE_NOTCONNECTED);
set(gui->win, MUIA_Window_Title, title);
/* Work-around for a bug in Lamp.mcc */
get(gui->app, MUIA_Application_Iconified, &tmp);
if (!tmp) set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_Connecting);
set(gui->stat, MUIA_Text_Contents, MSG_STATUS2_CONNECTING);
break;
case LOGGING_IN: /* Logging in */
prf_event(PRFE_CONNECT);
set(gui->inbut, MUIA_Disabled, TRUE);
set(gui->outbut, MUIA_Disabled, FALSE);
set(gui->rebut, MUIA_Disabled, FALSE);
sprintf(title, "Amster v%s · %s", AMSTER_VERSION, nap_server);
set(gui->win, MUIA_Window_Title, title);
/* Work-around for a bug in Lamp.mcc */
get(gui->app, MUIA_Application_Iconified, &tmp);
if (!tmp) set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_SendingData);
break;
case ONLINE: /* Online */
set(gui->inbut, MUIA_Disabled, TRUE);
set(gui->outbut, MUIA_Disabled, FALSE);
set(gui->rebut, MUIA_Disabled, FALSE);
sprintf(title, "Amster v%s · %s", AMSTER_VERSION, nap_server);
set(gui->win, MUIA_Window_Title, title);
/* Work-around for a bug in Lamp.mcc */
get(gui->app, MUIA_Application_Iconified, &tmp);
if (!tmp) set(gui->lamp, MUIA_Lamp_Color, MUIV_Lamp_Color_Ok);
gui_appicon(1);
break;
}
}
void gui_srvstat(int a, int b, int c)
{
gui_stat((char*)MSG_STATUS2_SONGSONLINE, b, a, c);
}
void gui_found(song s, int type)
{
if (type == 0) DoMethod(gui->searchpanel, SEARCH_FOUND, s);
else if (type == 1) DoMethod(gui->WI_Hotlist, HOTLIST_FOUND, s);
}
void localize_array(char *array[])
{
char **x;
for (x=array;*x;x++)
*x = (char *)((struct FC_String *)(*x))->msg;
}
void gui_stat(char *msg, ...)
{
static char buf[256];
va_list ap;
va_start(ap,msg);
vsprintf(buf,msg,ap);
va_end(ap);
set(gui->stat, MUIA_Text_Contents, buf);
}
void gui_appicon(int t)
{
static struct DiskObject *on, *off;
switch(t) {
case 0:
on = GetDiskObject("PROGDIR:Icons/Amster_online");
off = GetDiskObject("PROGDIR:Icons/Amster_offline");
break;
case -1:
if (on) FreeDiskObject(on);
if (off) FreeDiskObject(off);
break;
case 1:
if (on) set(gui->app, MUIA_Application_DiskObject, on);
break;
case 2:
if (off) set(gui->app, MUIA_Application_DiskObject, off);
break;
}
}